package com.laurentiuspilca.ssia.services;

import com.laurentiuspilca.ssia.model.Employee;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class BookService {


    @PostAuthorize("returnObject.roles.contains('reader')")
    public Employee getBookDetails(String name) {

        HashMap<String, Employee> records = new HashMap<>();
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("Karamazov Brothers");
        ArrayList<String> list2 = new ArrayList<>();
        list2.add("accountant");
        list2.add("reader");
        records.put("emma",new Employee("Karamazov Brothers",list1,list2));

        ArrayList<String> list3 = new ArrayList<>();
        list3.add("Beautiful Paris");
        ArrayList<String> list4 = new ArrayList<>();
        list4.add("researcher");
        records.put("natalie",new Employee("Natalie Parker",list3,list4));

        return records.get(name);
    }
}
